import React, { Component } from "react";
import * as echarts from "echarts";
// import ReactECharts from 'echarts-for-react';
export class Student extends Component {
  // 返回柱状图的配置对象
  // option = {
  //   xAxis: {
  //       type: 'category',
  //       data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  //   },
  //   yAxis: {
  //       type: 'value'
  //   },
  //   series: [{
  //       data: [120, 200, 150, 80, 70, 110, 130],
  //       type: 'bar'
  //   }]
  // };
  componentDidMount() {
    this.renderChart();
  }
  renderChart() {
    const chartContainer = document.getElementById("main");
    const myChart = echarts.init(chartContainer);
    const option = {
      legend: {
        data: ["运动区", "宿舍区", "教学区", "吸烟区", "干饭区"],
        textStyle: {
          color: "#fff",
        },
        icon: "circle", //把标题的icon改成圆形
      },
      xAxis: {
        type: "category",
        data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
      },
      yAxis: {
        type: "value",
      },
      series: [
        {
          name: "运动区",
          type: "line",
          smooth: true, //把折线修改成曲线
          stack: "Total",
          data: [5, 10, 20, 30, 40, 50, 60],
        },
        {
          name: "宿舍区",
          type: "line",
          smooth: true,
          stack: "Total",
          data: [5, 10, 20, 30, 40, 50, 60],
        },
        {
          name: "教学区",
          type: "line",
          smooth: true,
          stack: "Total",
          data: [5, 10, 20, 30, 40, 10, 60],
        },
        {
          name: "吸烟区",
          type: "line",
          stack: "Total",
          data: [5, 10, 20, 30, 40, 50, 60],
        },
        {
          name: "干饭区",
          type: "line",
          smooth: true,
          stack: "Total",
          data: [5, 10, 20, 30, 40, 50, 60],
        },
      ],
    };
    myChart.setOption(option);
  }
  render() {
    return (
      // <ReactECharts option={this.option} />
      <div id="main"></div>
    );
  }
}

export default Student;
